#include "test.h"
#include "ui_test.h"

Test::Test(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Test)
{
    ui->setupUi(this);   

    QTcpSocket *Socket = Client_connet::Get_Connet()->getM_fd();
    QJsonObject obj;

//    connect(Socket,&QTcpSocket::readyRead,this,[&]()
//    {
//        QByteArray data = Socket->readAll();
//        QJsonDocument js = QJsonDocument::fromJson(data);

//        if(js.isObject())
//        {
//            obj = js.object();
//            setText(obj);

//        }
//        else
//        {
//            qDebug()<<"数据为空";
//        }
//    });

}

Test::~Test()
{
    delete ui;
}

void Test::setText(QJsonObject js)
{
    QString str = ("cmd" + js["nickname"].toString() + js["password"].toString());
    ui->Recv->setText(str);
}

void Test::on_fasong_clicked()
{
    Client_connet::Get_Connet()->clearM_obj();

    QJsonObject js;
    js.insert("cmd",0);
    js.insert("nickname",ui->NIckname->text());
    js.insert("password",ui->Possword->text());

    Client_connet::Get_Connet()->set_obj(js);
    Client_connet::Get_Connet()->SendServer();

}



